package com.todo.delicacy.application.api.controller;

import com.todo.common.common.entity.response.BizResponse;
import com.todo.delicacy.application.convert.FoodConvert;
import com.todo.delicacy.application.entity.bo.RestaurantDetailBO;
import com.todo.delicacy.application.entity.bo.RestaurantInfoBO;
import com.todo.delicacy.application.service.RestaurantInfoService;
import com.todo.delicacy.service.api.RestaurantInfoApi;
import com.todo.delicacy.service.api.request.QueryRestaurantDetailByIdRequest;
import com.todo.delicacy.service.api.request.QueryRestaurantInfoByIdListRequest;
import com.todo.delicacy.service.api.response.RestaurantDetailResponse;
import com.todo.delicacy.service.api.response.RestaurantInfoResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author azhebuxing
 * @date 2025/2/25 22:55
 * @description
 */

@RestController
@RequestMapping("/api/restaurantInfo")
@Tag(name = "服务端-到店门店接口", description = "服务端-到店门店接口")
public class RestaurantInfoApiController implements RestaurantInfoApi {

    @Resource
    private RestaurantInfoService restaurantInfoService;


    @Override
    @Operation(summary = "根据id查询美食详情")
    @PostMapping("/queryRestaurantDetailById")
    public BizResponse<RestaurantDetailResponse> queryRestaurantDetailById(@RequestBody QueryRestaurantDetailByIdRequest request) {
        if (request == null || request.getRestaurantId() == null) {
            return BizResponse.paramError();
        }
        RestaurantDetailBO restaurantDetailBO = restaurantInfoService.queryRestaurantDetailById(request.getRestaurantId());
        return BizResponse.success(FoodConvert.convertToRestaurantDetailResponse(restaurantDetailBO));
    }

    @Override
    @Operation(summary = "根据id列表查询表详情")
    @PostMapping("/queryRestaurantInfoByIdList")
    public BizResponse<List<RestaurantInfoResponse>> queryRestaurantInfoByIdList(@RequestBody QueryRestaurantInfoByIdListRequest request) {
        if (request == null || CollectionUtils.isEmpty(request.getRestaurantIdList())) {
            return BizResponse.paramError();
        }
        List<RestaurantInfoBO> restaurantInfoBOS = restaurantInfoService.queryRestaurantInfoByIdList(request.getRestaurantIdList());
        return BizResponse.success(FoodConvert.convertToRestaurantInfoResponseList(restaurantInfoBOS));
    }
}
